package com.jair.crawler.mijia.proxy;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;

import org.apache.http.util.EncodingUtils;

public class Server2ClientThread extends Thread{
    private InputStream sis;
    private OutputStream cos;
 
    public Server2ClientThread(InputStream sis, OutputStream cos) {
        this.sis = sis;
        this.cos = cos;
    }
 
    public void run() {
        int length;
        byte bytes[] = new byte[256];
        while(true){
            try {
                if ((length = sis.read(bytes)) > 0) {
                    cos.write(bytes, 0, length);
                    cos.flush();
                    
                    String str  = EncodingUtils.getString(bytes, "UTF-8");
                    if(str.indexOf("sign=")>-1){
                    	System.out.println("服务器返回的内容"+str);
                    }
                } else if (length < 0){
                	
                	break;
                }
            } catch (Exception e) {
                //System.out.println("\nRequest Exception:");
            }
        }
    }
    
}
